﻿
using RFIDData.Data;
using RFIDData.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Phoenix_RFID
{
	public partial class EmployeeList : Form
	{
		Dbman db = new Dbman();


		public EmployeeList()
		{
			InitializeComponent();
		}

		private void EmployeeList_Load(object sender, EventArgs e)
		{
			cboDepartment.Items.Add("경영과");
			cboDepartment.Items.Add("인사과");
			cboDepartment.Items.Add("총무과");
			cboDepartment.Items.Add("영업팀");
			cboDepartment.Items.Add("개발팀");
			cboDepartment.Items.Add("기획팀");

			cboRank.Items.Add("사장");
			cboRank.Items.Add("부사장");
			cboRank.Items.Add("상무");
			cboRank.Items.Add("이사");
			cboRank.Items.Add("부장");
			cboRank.Items.Add("과장");
			cboRank.Items.Add("차장");
			cboRank.Items.Add("대리");
			cboRank.Items.Add("팀장");
			cboRank.Items.Add("사원");

			DgvEmployeelist.AutoGenerateColumns = false;
			DgvEmployeelist.DataSource = db.EmployeeList();
			
		}

		private void btnSearch_Click(object sender, EventArgs e)
		{
			if (cboDepartment.SelectedItem == null && cboRank.SelectedItem == null && txtName.Text == "")
			{
				DgvEmployeelist.AutoGenerateColumns = false;
				DgvEmployeelist.DataSource = db.EmployeeList();
			}
			else
			{
				Employee emp = new Employee
				{
					Name = txtName.Text,
					Department = cboDepartment.Text,
					Rank = cboDepartment.Text,
				};
				DgvEmployeelist.AutoGenerateColumns = false;
				DgvEmployeelist.DataSource = db.EmployeeList(emp);
			}
		}
	}
}

